package culton.android.online.movie;

import culton.android.R;
import culton.android.util.ImageDownloader;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class MovieDetailsActivity extends Activity {

	private static String posterURL = null;
	private static ImageView moviePoster;
	
	TextView movieTitle;
	TextView movieSynopsis;
	TextView genre;
	TextView duration;
	TextView rating;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.movie_details);

        //Get Movie and Cinema info from intent
        Bundle mBundle = getIntent().getExtras();

        //Download Movie Poster
	    posterURL = mBundle.getString("poster");
	    
        //Get Image View
        moviePoster = (ImageView) findViewById(R.id.moviePoster);
           
        if (posterURL != null && posterURL.length() != 0) {
        	ImageDownloader imgDownloader = new ImageDownloader();
        	imgDownloader.download(posterURL, moviePoster);
        } else {
        	Resources res = getResources();
        	Drawable d = res.getDrawable(R.drawable.notavailabledef);
        	moviePoster.setImageDrawable(d);
        }        
        	
        //Get TextView
        movieTitle = (TextView) findViewById(R.id.movieName);
        movieSynopsis = (TextView) findViewById(R.id.movieSynopsis);
        genre = (TextView) findViewById(R.id.genre);
        duration = (TextView) findViewById(R.id.duration);
        rating = (TextView) findViewById(R.id.rating);
        
        //Set TextView values
        movieTitle.setText(mBundle.getString("movieName"));
        movieSynopsis.setText(mBundle.getString("synopsis"));
        genre.setText(mBundle.getString("genre"));
        duration.setText(mBundle.getString("duration"));
        rating.setText(mBundle.getString("rating"));
	}
}
